package top.tagao.m03_beHavioralPatterns.b_10_comand.commands;

import top.tagao.m03_beHavioralPatterns.b_10_comand.editor.Editor;

/**
 * @author Viktor_Liu
 * @Date 2022/8/14 13:07
 */

public abstract class Command {
    public Editor editor;
    private String backup;

    Command(Editor editor) {
        this.editor = editor;
    }

    void backup() {
        backup = editor.textField.getText();
    }

    public void undo() {
        editor.textField.setText(backup);
    }

    public abstract boolean execute();
}